package com.kaishengit.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.kaishengit.entity.Employee;
import com.kaishengit.util.DBHelp;
import com.kaishengit.util.RowMapper;

public class EmployeeDao {
	
	private DBHelp<Employee> db = new DBHelp<Employee>();
	
	
	public Employee findByNameAndPwd(String name, String password)	{
		String sql = "select id,name,password,pic t_employee where name=? and password=?";
		return db.executeQueryForObject(sql, new EmployeeRowMapper(), name, password);
	}
	
	private class EmployeeRowMapper implements RowMapper<Employee> {
		
		public Employee mapperRow (ResultSet rs) throws SQLException {
			Employee employee = new Employee();
			employee.setId(rs.getString("id"));
			employee.setName(rs.getString("name"));
			employee.setPassword(rs.getString("password"));
			employee.setPic(rs.getString("pic"));
			return employee;
		}
	}
	
	

}
